<template>
  <div class="pop">
    <div class="pop-box result">
      <div class="pop-close" @click="this.close"></div>
      <div v-if="isReceive" class="content" style="width:5rem;margin:.4rem auto 0;">
        <div>您的游戏得分:</div>
        <div class="result-score">
          {{score}}
        </div>
        <div style="height:2.7rem">
          <div v-if="isReceive=='n'" class="result-desc">分数不够获得奖品哟！</div>
          <div v-for="prize in prizeList" :key="prize.id" class="result-desc">{{prize.name}}</div>
        </div>
      </div>
      <div v-if="isReceive" class="button-box">
        <div v-if="isReceive=='y'" class="tbutton get" @click="this.clickGet"></div>
        <div v-if="isReceive=='n'" class="tbutton again" @click="this.clickAgain"></div>
        <div class="tbutton list" @click="this.clickList"></div>
      </div>
    </div>
    <div class="pop-shadow"></div>
  </div>
</template>
<script>
import common from "../../../../wechat/static/common/common";

const getGoodsURL =
  "https://harmonygame.icebartech.com/api/html5/user/score/uploadTheScore";

export default {
  name: "TipPop",
  props: ["score"],
  mounted() {
    this.getGoods();
  },
  data() {
    return {
      isReceive: "",
      prizeList: []
    };
  },
  methods: {
    async getGoods() {
      this.sessionId = common.getCookie("sessionId");
      let score = this.score;
      let res = await this.$http.post(
        `${getGoodsURL}?sessionId=${this.sessionId}`,
        { score },
        { emulateJSON: true }
      );
      if (res.data.data.bussData) {
        let { isReceive, meno, prizeList } = res.data.data.bussData;
        this.isReceive = isReceive;
        this.prizeList = prizeList;
      }
    },
    clickList() {
      this.$emit("clickList");
    },
    clickAgain() {
      this.$emit("clickAgain");
    },
    clickGet() {
      this.$emit("clickGet");
    },
    close() {
      this.$emit("close");
    }
  }
};
</script>